<!-- 富文本组件 -->
<template>
  <VueUeditorWrap ref="editor"
                  v-model="value"
                  :config="myConfig"
                  @ready="ready"></VueUeditorWrap>
</template>

<script>
import VueUeditorWrap from "vue-ueditor-wrap";
export default {
  data () {
    return {
      token:'',
      ue: null,
      value: "",
      myConfig: {
        // 编辑器不自动被内容撑高
        autoHeightEnabled: false,
        // 初始容器高度
        initialFrameHeight: this.height,
        // 初始容器宽度
        initialFrameWidth: this.width,
        // 上传文件接口（这个地址是我为了方便各位体验文件上传功能搭建的临时接口，请勿在生产环境使用！！！）
        serverUrl: "http://rights.leyogame.cn/ueditor/php/controller.php",
        imageMaxSize:2048000,
        imageActionName:'uploadimage', 
        imageAllowFiles:['.png','.jpg','.jpeg','.gif','.bmp'],
        imageFieldName:'upfile',
        imageUrlPrefix:'',
        // UEditor 资源文件的存放路径，如果你使用的是 vue-cli 生成的项目，通常不需要设置该选项，vue-ueditor-wrap 会自动处理常见的情况，如果需要特殊配置，参考下方的常见问题2
        UEDITOR_HOME_URL: "/admin/ueditor/",
        // UEDITOR_HOME_URL: "/UEditor/",
        ...this.otherConfig
      }
    };
  },
  props: {
    otherConfig: {
      type: Object
    },
    width: {
      type: [Number, String],
      default: "100%"
    },
    height: {
      type: [Number, String],
      default: 240
    },
    default_value: {
      type: String,
      default: ''
    }
  },
  mounted () {
  },
  components: { VueUeditorWrap },
  computed: {},
  methods: {
    ready (editorInstance) {
      this.ue = editorInstance;
      if (this.default_value) {
        this.ue.setContent(this.default_value);
        this.value = this.default_value;
      }
      this.$emit("ready", editorInstance);
    },
  }
};
</script>
<style lang='scss' scoped>
</style>